var app = getApp();
Component({
	options: {
		addGlobalClass: true,
		categoryList: {}
	},
	data: {
		search: ''
	},
	ready: function() {

	},
	attached: function() {
		var that = this;
		app.globalAjax(
			'/api/category/list',
			"get", {},
			function(e) {
				if (e.code == 0) {
					that.setData({
						categoryList: e.categoryList
					})
				} else {
					wx.showToast({
						title: e.msg,
						icon: "none"
					});
				}
			})
	},
	methods: {
		searchIcon(e) { //输入
			this.setData({
				search: e.detail.value
			})
		},
		search() {
			if (this.data.search == "") {
				wx.showToast({
					title: "请输入商品名称",
					icon: "none"
				});
				return false;
			}
			wx.navigateTo({
				url: '/pages/classify/productlist/productlist?keys=' + this.data.search
			})
		}
	}
})
